<template>
    <div class="goodsIterm" @click="itemClick">
      <img :src="showImage" alt="" @load="imageLoad">
      <p>{{goodsItem.title}}</p>
    </div>
</template>

<script>
    export default {
        name: "GoodsListIterm",
      props:{
          goodsItem:{
            type:Object,
            default(){
            }
          }
      },
      computed:{
       showImage(){
         return this.goodsItem.url || this.goodsItem.img
       }
      },
      methods:{
        imageLoad(){
          //console.log('imageLoad');
          this.$bus.$emit('ItemImageLoad')

          /*if(this.$route.path.indexOf('/home')){
            this.$bus.$emit('homeItemImageLoad')
          }else if (this.$route.path.indexOf('/detail')) {
            this.$bus.$emit('detailItemImageLoad')
          }*/

        },
        itemClick(){
         this.$router.push('/detail/'+ this.goodsItem.id)
        }
      }
    }
</script>

<style scoped>

</style>
